#词云图
import pyecharts.options as opts
from pyecharts.charts import WordCloud
import pandas as pd

fpath = "../data/test.csv"
df = pd.read_csv(fpath, encoding='utf-8')

# df.loc[:, "数量"] = df["数量"].astype('int64')

v1 = df["单词"].unique()
v2 = df["数量"]

list = [tuple(z) for z in zip(list(v1), v2.to_list())]

(
    WordCloud()
    .add(series_name="热点分析", data_pair=list, word_size_range=[12, 48])
    .set_global_opts(
        title_opts=opts.TitleOpts(title="热点分析", title_textstyle_opts=opts.TextStyleOpts(font_size=23)),
        tooltip_opts=opts.TooltipOpts(is_show=True),
    )
    .render("../data/wordcloud.html")
)